<?php
session_start ();
// 判断用户是否已经登录
if (! isset ( $_SESSION ["userinfo"] ) and empty ( $_SESSION ["userinfo"] ["userid"] )) {
	session_unset ();
	session_destroy ();
	header ( "location:../index.php" );
	exit ();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Language" content="zh-CN">
<link href="./Resource/Style/base.yy.css" rel="stylesheet"
	type="text/css">
<link href="./Resource/Style/info.yy.css" rel="stylesheet"
	type="text/css">
</head>
<body>
<?php
require_once '../tools/SqlHelper.class.php';
if (isset ( $_POST ['user_submit'] ) and $_POST ['user_submit'] == '保存') {
	// 获取浏览器发过来的页面数据
	$user_id = $_SESSION ["userinfo"] ["userid"];
	// $user_id = "xufeng520";
	$dd_ischildren = $_POST ['getChild'];
	$dd_islong_distance_love = $_POST ['otherPlace'];
	$dd_like_type = $_POST ['likeType'];
	$dd_is_premarital_sex = $_POST ['sexBefore'];
	$dd_live_with_parents = $_POST ['liveWithParents'];
	$dd_charm_point = $_POST ['sexyPart'];
	$dd_hobby_str = "";
	for($i = 0; $i < 20; $i ++) {
		$str = "int_" . $i;
		if ($_POST [$str] == "on") {
			$dd_hobby_str = $dd_hobby_str . "1";
		} else {
			$dd_hobby_str = $dd_hobby_str . "0";
		}
	}
	$dd_personality = "";
	for($i = 0; $i < 18; $i ++) {
		$str = "chc_" . $i;
		if ($_POST [$str] == "on") {
			$dd_personality = $dd_personality . "1";
		} else {
			$dd_personality = $dd_personality . "0";
		}
	}
	/* $dd_hobby_str = str_split ( $dd_hobby, 1 );
	$dd_personality = str_split ( $dd_personality1, 1 ); */
	$sql = "UPDATE `detail_data_tb` SET `dd_ischildren`='$dd_ischildren', `dd_islong_distance_love`='$dd_islong_distance_love',
			 `dd_like_type`='$dd_like_type', `dd_is_premarital_sex`='$dd_is_premarital_sex', `dd_live_with_parents`='$dd_live_with_parents', 
			`dd_charm_point`='$dd_charm_point', `dd_hobby`='$dd_hobby_str', `dd_personality`='$dd_personality' WHERE `user_id`='$user_id'";
	$sqlHelper = new SqlHelper ();
	$res = $sqlHelper->execute_dql ( $sql );
	if (! $res) {
		echo "<script>alert('保存资料失败')</script>";
	} else {
		echo "<script>alert('保存资料成功')</script>";
	}
	// 关闭连接
	// mysql_free_result ( $res );
	$sqlHelper->close_connect ();
} else {
	$user_id = $_SESSION ["userinfo"] ["userid"];
	// $user_id = "xufeng520";
	$sql = "select * from `detail_data_tb` where `user_id`='$user_id'";
	// 创建一个SqlHelper对象
	$sqlHelper = new SqlHelper ();
	$row = $sqlHelper->execute_dql ( $sql );
	$res = mysql_fetch_array ( $row );
	// 关闭连接
	$dd_ischildren = $res ['dd_ischildren'];
	$dd_islong_distance_love = $res ['dd_islong_distance_love'];
	$dd_like_type = $res ['dd_like_type'];
	$dd_is_premarital_sex = $res ['dd_is_premarital_sex'];
	$dd_live_with_parents = $res ['dd_live_with_parents'];
	$dd_charm_point = $res ['dd_charm_point'];
	$dd_hobby = $res ['dd_hobby'];
	$dd_personality1 = $res ['dd_personality'];
	mysql_free_result ( $row );
	$sqlHelper->close_connect ();
	
	$dd_hobby_str = str_split ( $dd_hobby, 1 );
	$dd_personality = str_split ( $dd_personality1, 1 );
}
?>
		<div class="yy_main_R">
		<nav>
			<div class="info_nav">
				<ul>
					<li><a href="./baseData.php">基本资料</a></li>
					<li><a class="a_out" href="#">详细资料</a></li>
					<li><a href="./soliloquy.php">内心独白</a></li>
					<li><a href="./uploadingPhoto.php">上传头像</a></li>
					<li><a href="./myPhoto.php">我的相册</a></li>
					<li><a href="./PersonalCondition.php">征友条件</a></li>
					<li><a href="./changePassword.php">修改密码</a></li>
				</ul>
			</div>
		</nav>
		<form action="./Details.php" method="post">
			<div class="info_con">
				<ol class="detailed">
					<li><label>是否想要小孩：</label> <select id="sel_child" name="getChild">
							<option class="selectList" value="0"
								<?php if($dd_ischildren == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="1"
								<?php if($dd_ischildren == "1"){echo "selected='true'";}?>>想</option>
							<option class="selectList" value="2"
								<?php if($dd_ischildren == "2"){echo "selected='true'";}?>>不想</option>
							<option class="selectList" value="3"
								<?php if($dd_ischildren == "3"){echo "selected='true'";}?>>还没想好</option>
					</select></li>
					<li><label>是否接受异地恋：</label> <select id="sel_diffArea"
						name="otherPlace">
							<option class="selectList" value="0"
								<?php if($dd_islong_distance_love == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="1"
								<?php if($dd_islong_distance_love == "1"){echo "selected='true'";}?>>能</option>
							<option class="selectList" value="2"
								<?php if($dd_islong_distance_love == "2"){echo "selected='true'";}?>>看情况</option>
							<option class="selectList" value="3"
								<?php if($dd_islong_distance_love == "3"){echo "selected='true'";}?>>不能</option>
					</select></li>
					<li><label>喜欢的异性类型：</label> <select id="sel_likeType"
						name="likeType">
							<option class="selectList" value="0"
								<?php if($dd_like_type == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="6"
								<?php if($dd_like_type == "6"){echo "selected='true'";}?>>成熟魅力</option>
							<option class="selectList" value="5"
								<?php if($dd_like_type == "5"){echo "selected='true'";}?>>落落大方</option>
							<option class="selectList" value="7"
								<?php if($dd_like_type == "7"){echo "selected='true'";}?>>眉清目秀</option>
							<option class="selectList" value="8"
								<?php if($dd_like_type == "8"){echo "selected='true'";}?>>性感妩媚</option>
							<option class="selectList" value="2"
								<?php if($dd_like_type == "2"){echo "selected='true'";}?>>善解人意</option>
							<option class="selectList" value="9"
								<?php if($dd_like_type == "9"){echo "selected='true'";}?>>雍容华贵</option>
							<option class="selectList" value="1"
								<?php if($dd_like_type == "1"){echo "selected='true'";}?>>活泼开朗</option>
							<option class="selectList" value="3"
								<?php if($dd_like_type == "3"){echo "selected='true'";}?>>娇小可爱</option>
							<option class="selectList" value="4"
								<?php if($dd_like_type == "4"){echo "selected='true'";}?>>温柔体贴</option>
					</select></li>
					<li><label>能否接受婚前性行为：</label> <select id="sel_sexBefore"
						name="sexBefore">
							<option class="selectList" value="0"
								<?php if($dd_is_premarital_sex == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="1"
								<?php if($dd_is_premarital_sex == "1"){echo "selected='true'";}?>>能</option>
							<option class="selectList" value="2"
								<?php if($dd_is_premarital_sex == "2"){echo "selected='true'";}?>>看情况</option>
							<option class="selectList" value="3"
								<?php if($dd_is_premarital_sex == "3"){echo "selected='true'";}?>>不能</option>
					</select></li>
					<li><label>是否愿意和父母同住：</label> <select id="sel_liveWithParents"
						name="liveWithParents">
							<option class="selectList" value="0"
								<?php if($dd_live_with_parents == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="1"
								<?php if($dd_live_with_parents == "1"){echo "selected='true'";}?>>愿意</option>
							<option class="selectList" value="2"
								<?php if($dd_live_with_parents == "2"){echo "selected='true'";}?>>看情况</option>
							<option class="selectList" value="3"
								<?php if($dd_live_with_parents == "3"){echo "selected='true'";}?>>不愿意</option>
					</select></li>
					<li><label>你最有魅力的部位：</label> <select id="sel_sexyPart"
						name="sexyPart">
							<option class="selectList" value="0"
								<?php if($dd_charm_point == "0"){echo "selected='true'";}?>>未填写</option>
							<option class="selectList" value="1"
								<?php if($dd_charm_point == "1"){echo "selected='true'";}?>>笑容</option>
							<option class="selectList" value="2"
								<?php if($dd_charm_point == "2"){echo "selected='true'";}?>>眉毛</option>
							<option class="selectList" value="3"
								<?php if($dd_charm_point == "3"){echo "selected='true'";}?>>眼睛</option>
							<option class="selectList" value="4"
								<?php if($dd_charm_point == "4"){echo "selected='true'";}?>>头发</option>
							<option class="selectList" value="5"
								<?php if($dd_charm_point == "5"){echo "selected='true'";}?>>鼻梁</option>
							<option class="selectList" value="6"
								<?php if($dd_charm_point == "6"){echo "selected='true'";}?>>嘴唇</option>
							<option class="selectList" value="7"
								<?php if($dd_charm_point == "7"){echo "selected='true'";}?>>牙齿</option>
							<option class="selectList" value="8"
								<?php if($dd_charm_point == "8"){echo "selected='true'";}?>>颈部</option>
							<option class="selectList" value="9"
								<?php if($dd_charm_point == "9"){echo "selected='true'";}?>>耳朵</option>
							<option class="selectList" value="10"
								<?php if($dd_charm_point == "10"){echo "selected='true'";}?>>手</option>
							<option class="selectList" value="11"
								<?php if($dd_charm_point == "11"){echo "selected='true'";}?>>胳膊</option>
							<option class="selectList" value="12"
								<?php if($dd_charm_point == "12"){echo "selected='true'";}?>>胸部</option>
							<option class="selectList" value="13"
								<?php if($dd_charm_point == "13"){echo "selected='true'";}?>>腰部</option>
							<option class="selectList" value="14"
								<?php if($dd_charm_point == "14"){echo "selected='true'";}?>>脚</option>
							<option class="selectList" value="15"
								<?php if($dd_charm_point == "15"){echo "selected='true'";}?>>腿</option>
							<option class="selectList" value="16"
								<?php if($dd_charm_point == "16"){echo "selected='true'";}?>>臀部</option>
					</select></li>
				</ol>
				<div class="interest">
					<label>你的兴趣爱好：</label>
					<ul id="chk_interests">
						<li class="checkBox"><input name="int_0" type="checkbox"
							<?php if($dd_hobby_str[0]=="1"){echo "checked='checked'";}?>> <label
							for="int_0">上网</label></li>
						<li class="checkBox"><input name="int_1" type="checkbox"
							<?php if($dd_hobby_str[1]=="1"){echo "checked='checked'";}?>> <label
							for="int_1">研究汽车</label></li>
						<li class="checkBox"><input name="int_2" type="checkbox"
							<?php if($dd_hobby_str[2]=="1"){echo "checked='checked'";}?>> <label
							for="int_2">养小动物</label></li>
						<li class="checkBox"><input name="int_3" type="checkbox"
							<?php if($dd_hobby_str[3]=="1"){echo "checked='checked'";}?>> <label
							for="int_3">摄影</label></li>
						<li class="checkBox"><input name="int_4" type="checkbox"
							<?php if($dd_hobby_str[4]=="1"){echo "checked='checked'";}?>> <label
							for="int_4">看电影</label></li>
						<li class="checkBox"><input name="int_5" type="checkbox"
							<?php if($dd_hobby_str[5]=="1"){echo "checked='checked'";}?>> <label
							for="int_5">听音乐</label></li>
						<li class="checkBox"><input name="int_6" type="checkbox"
							<?php if($dd_hobby_str[6]=="1"){echo "checked='checked'";}?>> <label
							for="int_6">写作</label></li>
						<li class="checkBox"><input name="int_7" type="checkbox"
							<?php if($dd_hobby_str[7]=="1"){echo "checked='checked'";}?>> <label
							for="int_7">购物</label></li>
						<li class="checkBox"><input name="int_8" type="checkbox"
							<?php if($dd_hobby_str[8]=="1"){echo "checked='checked'";}?>> <label
							for="int_8">做手工艺</label></li>
						<li class="checkBox"><input name="int_9" type="checkbox"
							<?php if($dd_hobby_str[9]=="1"){echo "checked='checked'";}?>> <label
							for="int_9">做园艺</label></li>
						<li class="checkBox"><input name="int_10" type="checkbox"
							<?php if($dd_hobby_str[10]=="1"){echo "checked='checked'";}?>> <label
							for="int_10">跳舞</label></li>
						<li class="checkBox"><input name="int_11" type="checkbox"
							<?php if($dd_hobby_str[11]=="1"){echo "checked='checked'";}?>> <label
							for="int_11">看展览</label></li>
						<li class="checkBox"><input name="int_12" type="checkbox"
							<?php if($dd_hobby_str[12]=="1"){echo "checked='checked'";}?>> <label
							for="int_12">烹饪</label></li>
						<li class="checkBox"><input name="int_13" type="checkbox"
							<?php if($dd_hobby_str[13]=="1"){echo "checked='checked'";}?>> <label
							for="int_13">读书</label></li>
						<li class="checkBox"><input name="int_14" type="checkbox"
							<?php if($dd_hobby_str[14]=="1"){echo "checked='checked'";}?>> <label
							for="int_14">绘画</label></li>
						<li class="checkBox"><input name="int_15" type="checkbox"
							<?php if($dd_hobby_str[15]=="1"){echo "checked='checked'";}?>> <label
							for="int_15">研究计算机</label></li>
						<li class="checkBox"><input name="int_16" type="checkbox"
							<?php if($dd_hobby_str[16]=="1"){echo "checked='checked'";}?>> <label
							for="int_16">做运动</label></li>
						<li class="checkBox"><input name="int_17" type="checkbox"
							<?php if($dd_hobby_str[17]=="1"){echo "checked='checked'";}?>> <label
							for="int_17">旅游</label></li>
						<li class="checkBox"><input name="int_18" type="checkbox"
							<?php if($dd_hobby_str[18]=="1"){echo "checked='checked'";}?>> <label
							for="int_18">玩电子游戏</label></li>
						<li class="checkBox"><input name="int_19" type="checkbox"
							<?php if($dd_hobby_str[19]=="1"){echo "checked='checked'";}?>> <label
							for="int_19">其它</label></li>
					</ul>
				</div>
				<div class="interest">
					<label>你的个性特征：</label>
					<ul id="chk_personalitys">
						<li class="checkBox"><input name="chc_0" type="checkbox"
							<?php if($dd_personality[0]=="1"){echo "checked='checked'";}?>> <label
							for="chc_0"> 宅</label></li>
						<li class="checkBox"><input name="chc_1" type="checkbox"
							<?php if($dd_personality[1]=="1"){echo "checked='checked'";}?>> <label
							for="chc_1"> 感性</label></li>
						<li class="checkBox"><input name="chc_2" type="checkbox"
							<?php if($dd_personality[2]=="1"){echo "checked='checked'";}?>> <label
							for="chc_2"> 体贴</label></li>
						<li class="checkBox"><input name="chc_3" type="checkbox"
							<?php if($dd_personality[3]=="1"){echo "checked='checked'";}?>> <label
							for="chc_3"> 憨厚</label></li>
						<li class="checkBox"><input name="chc_4" type="checkbox"
							<?php if($dd_personality[4]=="1"){echo "checked='checked'";}?>> <label
							for="chc_4"> 稳重</label></li>
						<li class="checkBox"><input name="chc_5" type="checkbox"
							<?php if($dd_personality[5]=="1"){echo "checked='checked'";}?>> <label
							for="chc_5"> 好强</label></li>
						<li class="checkBox"><input name="chc_6" type="checkbox"
							<?php if($dd_personality[6]=="1"){echo "checked='checked'";}?>> <label
							for="chc_6"> 冷静</label></li>
						<li class="checkBox"><input name="chc_7" type="checkbox"
							<?php if($dd_personality[7]=="1"){echo "checked='checked'";}?>> <label
							for="chc_7"> 温柔</label></li>
						<li class="checkBox"><input name="chc_8" type="checkbox"
							<?php if($dd_personality[8]=="1"){echo "checked='checked'";}?>> <label
							for="chc_8"> 自我</label></li>
						<li class="checkBox"><input name="chc_9" type="checkbox"
							<?php if($dd_personality[9]=="1"){echo "checked='checked'";}?>> <label
							for="chc_9"> 闷骚</label></li>
						<li class="checkBox"><input name="chc_10" type="checkbox"
							<?php if($dd_personality[10]=="1"){echo "checked='checked'";}?>>
							<label for="chc_10"> 正直</label></li>
						<li class="checkBox"><input name="chc_11" type="checkbox"
							<?php if($dd_personality[11]=="1"){echo "checked='checked'";}?>>
							<label for="chc_11"> 幽默</label></li>
						<li class="checkBox"><input name="chc_12" type="checkbox"
							<?php if($dd_personality[12]=="1"){echo "checked='checked'";}?>>
							<label for="chc_12"> 讲义气</label></li>
						<li class="checkBox"><input name="chc_13" type="checkbox"
							<?php if($dd_personality[13]=="1"){echo "checked='checked'";}?>>
							<label for="chc_13"> 孝顺</label></li>
						<li class="checkBox"><input name="chc_14" type="checkbox"
							<?php if($dd_personality[14]=="1"){echo "checked='checked'";}?>>
							<label for="chc_14"> 勇敢</label></li>
						<li class="checkBox"><input name="chc_15" type="checkbox"
							<?php if($dd_personality[15]=="1"){echo "checked='checked'";}?>>
							<label for="chc_15"> 有责任心</label></li>
						<li class="checkBox"><input name="chc_16" type="checkbox"
							<?php if($dd_personality[16]=="1"){echo "checked='checked'";}?>>
							<label for="chc_16"> 好动</label></li>
						<li class="checkBox"><input name="chc_17" type="checkbox"
							<?php if($dd_personality[17]=="1"){echo "checked='checked'";}?>>
							<label for="chc_17"> 随和</label></li>
					</ul>
				</div>
				<div class="keep">
					<input type="submit" name="user_submit" value="保存" />
				</div>
			</div>
		</form>
	</div>
</body>
</html>